﻿using System.Collections.Generic;
using System.Windows;


namespace TrackClasses
{
    public partial class Road
    {
        public float MaxTrackWidth
        {
            get { return 1024; }
        }

        public float MaxTrackHeight
        {
            get { return 1024; }
        }



        public int speedDeltaY = 0;
        public int speedDeltaX = 0;
        public double prevAngle = 0;
        public double curPosX;
        public double curPosY;
        public double curPosPrevX;
        public double curPosPrevY;
        public double deltaFi;

        private List<RoadPart> _roadParts = new List<RoadPart>();
        public RoadPart[] RoadParts
        {
            get { return _roadParts.ToArray(); }
        }

        public void RemoveLastRoadPart()
        {
            _roadParts.RemoveAt(_roadParts.Count - 1);
        }

        public void AddRoadPart(RoadPart p)
        {
            _roadParts.Add(p);
        }

        public RoadPart GetStartRoadPart()
        {
            if (_roadParts.Count == 0)
                return null;
            return _roadParts[0];
        }

        public RoadPart GetFinishRoadPart()
        {
            if (_roadParts.Count == 0)
                return null;
            return _roadParts[_roadParts.Count - 1];
        }

        public List<float> CarsStartPositionX { get; private set; }
        public List<float> CarsStartPositionY { get; private set; }

        

        public static Road GetTestRoad()
        {
            Road r = new Road();
            r.CarsStartPositionX = new List<float>();
            r.CarsStartPositionY = new List<float>();
            r.CarsStartPositionX.Add(420);
            r.CarsStartPositionY.Add(950);
            r.CarsStartPositionX.Add(460);
            r.CarsStartPositionY.Add(950);
            r.AddRoadPart(new RoadPart(418, 995, 514, 995));
            r.AddRoadPart(new RoadPart(413, 934, 488, 928));
            r.AddRoadPart(new RoadPart(424, 867, 508, 863));
            r.AddRoadPart(new RoadPart(450, 815, 529, 817));
            r.AddRoadPart(new RoadPart(499, 775, 591, 805));
            r.AddRoadPart(new RoadPart(538, 748, 622, 802));
            r.AddRoadPart(new RoadPart(640, 726, 668, 800));
            r.AddRoadPart(new RoadPart(695, 720, 726, 790));
            r.AddRoadPart(new RoadPart(756, 689, 813, 765));
            r.AddRoadPart(new RoadPart(787, 652, 836, 695));
            r.AddRoadPart(new RoadPart(780, 591, 849, 584));
            r.AddRoadPart(new RoadPart(779, 522, 851, 495));
            r.AddRoadPart(new RoadPart(776, 439, 856, 400));
            r.AddRoadPart(new RoadPart(727, 364, 800, 344));
            r.AddRoadPart(new RoadPart(666, 327, 713, 287));
            r.AddRoadPart(new RoadPart(588, 330, 568, 281));
            r.AddRoadPart(new RoadPart(483, 363, 449, 300));
            r.AddRoadPart(new RoadPart(414, 411, 367, 340));
            r.AddRoadPart(new RoadPart(389, 450, 342, 383));
            r.AddRoadPart(new RoadPart(384, 477, 321, 453));
            r.AddRoadPart(new RoadPart(385, 516, 320, 524));
            r.AddRoadPart(new RoadPart(403, 549, 341, 582));
            r.AddRoadPart(new RoadPart(453, 561, 378, 601));
            r.AddRoadPart(new RoadPart(479, 601, 391, 635));
            r.AddRoadPart(new RoadPart(457, 672, 385, 675));
            r.AddRoadPart(new RoadPart(408, 741, 326, 718));
            r.AddRoadPart(new RoadPart(357, 784, 291, 732));
            r.AddRoadPart(new RoadPart(295, 800, 254, 736));
            r.AddRoadPart(new RoadPart(247, 814, 213, 734));
            r.AddRoadPart(new RoadPart(195, 798, 164, 730));
            r.AddRoadPart(new RoadPart(146, 782, 132, 684));
            r.AddRoadPart(new RoadPart(83, 742, 128, 645));
            r.AddRoadPart(new RoadPart(63, 691, 128, 615));
            r.AddRoadPart(new RoadPart(53, 615, 128, 566));
            r.AddRoadPart(new RoadPart(52, 539, 126, 510));
            r.AddRoadPart(new RoadPart(51, 499, 140, 470));
            r.AddRoadPart(new RoadPart(62, 472, 142, 450));
            r.AddRoadPart(new RoadPart(67, 449, 143, 403));
            r.AddRoadPart(new RoadPart(65, 374, 149, 361));
            r.AddRoadPart(new RoadPart(60, 316, 148, 299));
            r.AddRoadPart(new RoadPart(52, 279, 147, 264));
            r.AddRoadPart(new RoadPart(47, 250, 141, 231));
            r.AddRoadPart(new RoadPart(60, 184, 166, 168));
            r.AddRoadPart(new RoadPart(62, 149, 189, 157));
            r.AddRoadPart(new RoadPart(84, 107, 217, 135));
            r.AddRoadPart(new RoadPart(160, 51, 241, 131));
            r.AddRoadPart(new RoadPart(242, 41, 299, 126));
            r.AddRoadPart(new RoadPart(335, 37, 373, 127));
            r.AddRoadPart(new RoadPart(416, 44, 434, 137));
            r.AddRoadPart(new RoadPart(520, 55, 486, 137));
            r.AddRoadPart(new RoadPart(596, 68, 579, 145));
            r.AddRoadPart(new RoadPart(649, 67, 660, 141));
            r.AddRoadPart(new RoadPart(718, 77, 726, 144));
            r.AddRoadPart(new RoadPart(783, 80, 805, 142));
            r.AddRoadPart(new RoadPart(863, 80, 889, 132));
            r.AddRoadPart(new RoadPart(908, 65, 935, 116));
            r.AddRoadPart(new RoadPart(952, 51, 975, 105));



          
            return r;
        }
    }
}
